<script setup lang="ts">
import { useImageCache } from "~/composables/useImageCache";

// 使用图片缓存功能
const { getCoverImage } = useImageCache();

const props = defineProps({
  itemData: {
    type: Object,
    default: () => {},
  },
});
</script>

<template>
  <div class="service-item" v-if="props.itemData.id">
    <img class="bg" :src="getCoverImage(props.itemData.coverPic)" alt="" />
    <h2>{{ props.itemData.title }}</h2>
    <h3>{{ props.itemData.description }}</h3>
  </div>
</template>

<style scoped lang="scss">
.service-item {
  width: 100%;
  height: 360px;
  position: relative;
  cursor: pointer;
  &:hover {
    .bg {
      transform: scale(1.1);
    }
  }
  .bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    transition: all 0.2s;
  }
  h2 {
    color: #fff;
    position: relative;
    z-index: 1;
    padding: 20px 0 0 20px;
    margin-bottom: 10px;
    font-size: 22px;
  }
  h3 {
    color: #fff;
    position: relative;
    z-index: 1;
    padding: 0 0 0 20px;
    margin-bottom: 6px;
  }
}
</style>
